package zengqiang.day04

import kotlin.reflect.KProperty

fun main(args: Array<String>) {
    var s=SmallSon()
    s.压岁钱=100
    println(s.压岁钱)//50

}
class SmallSon{
    var 压岁钱:Int by Mother()
}

class Mother{
    var 儿子压岁钱=0
    var 妈妈小金库=0
    operator fun getValue(smallSon: SmallSon, property: KProperty<*>): Int {
        return 儿子压岁钱
    }

    operator fun setValue(smallSon: SmallSon, property: KProperty<*>, i: Int) {
        儿子压岁钱+=50
        妈妈小金库+=i-50
    }
}